/**
 * Free software.
 */

package org.nanhill.commons.collection;

import java.util.Iterator;

public class ArrayIterator<E> implements Iterator<E> {
	private E[] array;

	private int location;

	public void setArray(E[] array) {
		this.array = array;
		location = 0;
	}

	public ArrayIterator(E[] array) {
		this.array = array;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#hasNext()
	 */
	public boolean hasNext() {
		return location < array.length;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#next()
	 */
	public E next() {
		E item =  array[location];
		location++;
		return item;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#remove()
	 */
	public void remove() {
		throw new UnsupportedOperationException(
				"This iterator unsupport remove operation.");

	}

}